<template>
  <div>
    <el-input v-model="pagePram.name" placeholder="请输入车辆名称" style="width: 200px;height: 30px"></el-input>
    <el-input v-model="pagePram.price" placeholder="请输入价格" style="width: 200px;height: 30px"></el-input>
    <el-button type="primary" @click="sou">搜索</el-button>
    <el-button type="primary" @click="xinjian">新建车辆</el-button> <br>

    <div v-for="n in numTables" :key="n" style="width: 300px" class="dicc">
      <ul>
        <li>

          <el-form label-width="80px" class="from">
            <el-table :data="page.list" border style="width: 100%">
              <el-table-column prop="pic" label="车辆照片"></el-table-column>
              <el-table-column prop="name" label="车辆名称"></el-table-column>
              <el-table-column prop="colour" label="车辆颜色"></el-table-column>
              <el-table-column prop="price" label="车辆价格"></el-table-column>
              <el-table-column label="操作">
                <template slot-scope="scope">
                  <el-button type="primary" @click="xiang" >查看详情</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-form>
        </li>
      </ul>
    </div>

    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pagePram.page"
      :page-sizes="[2, 4, 6, 8]"
      :page-size="pagePram.size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="page.total"
      class="page">
    </el-pagination>

    <!--详情弹窗-->
    <el-dialog title="详情" :visible.sync="dialogviewVisible">
      <img src="https://car-goods.oss-cn-beijing.aliyuncs.com/car/20240601121259.png" alt="图片正在加载中……" width="200px" height="160px"> <br>
      茶名：{{xin.name}} <br>
      颜色：{{xin.colour}} <br>
      价格：{{xin.price}} <br>
      <el-button type="success" @click="tan">购买</el-button>
      <el-button type="success" @click="dialogviewVisible=false">返回列表</el-button>
    </el-dialog>

  </div>
</template>

<script>
export default {
  data() {
    return {
      numTables: 6,
      car:{},
      xin:{},
      dialogviewVisible:false,
      pagePram:{
        page:1,
        size:5,
        name:'',
        label:'',
      },
      page:{}
    };
  },
  methods: {
    //搜索
    sou(){
      this.pagePram.page=1;
      this.initPerson();
    },
    handleSizeChange(val) {
      this.pagePram.size = val;
      this.initPerson();
    },
    handleCurrentChange(val) {
      this.pagePram.page = val;
      this.initPerson();
    },

    tan(){
      this.$router.push("CheckView");
    },
    xiang(e){
      this.xin=e;
      this.dialogviewVisible=true;
    },
    initPerson(){
      this.axios.post("/carInfo/getCarInfo",this.pagePram).then(res=>{
        this.page=res.data.data;
      })
    }
  },
  created() {
    this.initPerson();
  }
};
</script>

<style>
.from{
  border: 1px solid #ccc;
  padding: 10px;
}
.dicc{
  display: inline;
  flex-wrap: wrap;
  float: left;
}
li{
  display: inline;
  overflow: hidden;
  margin-right: 10px;
  list-style: none;
}
.page{
  width: 100%;
  float: left;
}
</style>